﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Text;

namespace Utility.BehaviourTree
{
	[HideFromCreateMenu]
	public class BTRootNode : DecoratorNode
	{
		static StringBuilder stringBuilder = new StringBuilder ();

		bool running = true;

		public BTRootNode ()
		{
			DataBoard = new DataBoard ();
		}

		protected override Status OnUpdate ()
		{
			ChildNode.Update ();
			return running ? Status.Running : Status.Success;
		}

		public new void Update ()
		{
			Update (0);
		}

		public void Update (float dt)
		{
			DataBoard.UpdateTime (dt);
			base.Update ();
		}

		public string GetTreeString ()
		{
			if (ChildNode != null)
			{
				string str = BuildString (stringBuilder).ToString ();
				stringBuilder.Clear ();
				return str;
			}
			else
			{
				return "Behaviour Tree is empty";
			}
		}
	}
}